import os


    
def scan_dir(current_dir,current_list):
    size = 0
    temp_dir_list = []
    global total_size
    for c_file in current_list:
        c_dir_file = os.path.join(current_dir,c_file)
        if os.path.isfile(c_dir_file) == True:
            size = os.path.getsize(c_dir_file)
            total_size += size
        else : 
            c_dirs.append(os.path.abspath(c_dir_file))                  
            temp_dir_list = os.listdir(c_dir_file)
            scan_dir(c_dir_file,temp_dir_list) 
    
        
                
# ~ main_dir = input ("请输入目录查看目录大小：\n")
main_dir = "D:\python_work"   
total_size = 0
current_list = os.listdir(main_dir)
c_dirs = []
scan_dir(main_dir,current_list)
print (str(len(c_dirs)) + '个文件夹')
print (main_dir + "目录总大小为" + str(total_size) + "字节")
